home *** CD-ROM | disk | FTP | other *** search
/ PC World Interactive 7 / PC World Interactive 7.iso / online / motor.EXE / ARDAS.PAS < prev    next >
Pascal/Delphi Source File  |  1991-10-04  |  10KB  |  264 lines

  1. begin
  2. write('ѥ');
  3. end.
  4. cord
  5.       x1,y1,x2,y2,group:integer;
  6.     end;
  7.    poin=record
  8.          x,y :longint;
  9.          index:string[10];
  10.    end;
  11.      points=array [1..2200] of poin;
  12.  
  13. var
  14.    min,miny: integer;
  15.    point:points;
  16.    f1,f2,f3,f4,f5 :text;
  17.    number:integer;
  18.    count:integer;
  19.    getx,gety    :integer;
  20.    counth,countv:integer;
  21.    x1limit,x2limit,y1limit,y2limit :integer;
  22.    i,j,d1,d2 :integer;
  23.    rec   :string[10];
  24.    ylocation,xlocation :integer;
  25.    x1,x2,y1,y2 :string[5];
  26.    temp:real;
  27.    groupv,grouph :longint;
  28.    grdriver,grmode :integer;
  29.    horz,ver,lines:array[1..200] of lin;
  30.    str2,str1,s   :string;
  31.    temp1 :real;
  32.    label 10,20,30;
  33.  
  34.    procedure quicksort(var a: points; Lo,Hi: integer);
  35.  
  36.              procedure sort(l,r: integer);
  37.                        var
  38.                           i,j:integer;
  39.                           x,y: string[10];
  40.                           xp,yp :poin;
  41.                        begin
  42.                             i:=l; j:=r; x:=a[(l+r) DIV 2].index;
  43.                               repeat
  44.                                   while a[i].index<x do i:=i+1;
  45.                                       while x<a[j].index do j:=j-1;
  46.                                           if i<=j then
  47.                                               begin
  48.                                                     yp:=a[i];
  49.                                                     a[i]:=a[j];
  50.                                                     a[j]:=yp;
  51.                                                     i:=i+1; j:=j-1;
  52.                                               end;
  53.                                           until i>j;
  54.                                     if l<j then sort(l,j);
  55.                                     if i<r then sort(i,r);
  56.                                   end;
  57.  
  58.                             begin {quicksort};
  59.                               sort(Lo,Hi);
  60.                             end;
  61.  
  62.  
  63.    begin
  64.         min:=29999;
  65.         miny:=29999;
  66.         assign(f5,'dosya.dat');reset(f5);readln(f5,s);
  67.         assign(f1,s+'.dxf');
  68.         reset(f1);
  69.         str2:='';
  70.         count:=0;
  71.         {****** READLN ****}
  72.         {****** READLN ****}
  73.         {****** READLN ****}
  74.          while str2 <> 'ENDSEC' do
  75.                begin
  76.                     readln(f1,str2);
  77.                     if str2='ENTITIES' then
  78.                        begin
  79.                             readln(f1,str2);
  80.                             rec:='start';
  81.                        end;
  82.                     if rec='start' then
  83.                        begin
  84.                             readln(f1,str2);
  85.                             if str2='LINE' then
  86.                                begin
  87.                                     count:=count+1;
  88.                                     readln(f1,str2);
  89.                                     readln(f1,str2);
  90.                                     readln(f1,str2);
  91.                                     readln(f1,x1);
  92.                                     readln(f1,str2);
  93.                                     readln(f1,y1);
  94.                                     readln(f1,str2);
  95.                                     readln(f1,x2);
  96.                                     readln(f1,str2);
  97.                                     readln(f1,y2);
  98.                                     val(x1,lines[count].x1,i);
  99.                                     val(y1,lines[count].y1,i);
  100.                                     val(x2,lines[count].x2,i);
  101.                                     val(y2,lines[count].y2,i);
  102.  
  103.                                end;
  104.  
  105.                end;
  106.                
  107.          end;
  108.          counth:=0;
  109.          countv:=0;
  110.          for d1:=1 to count do
  111.              begin
  112.                   if (lines[d1].x1-lines[d1].x2)=0 then
  113.                      begin
  114.                        countv:=countv+1;
  115.                        ver[countv].x1:=lines[d1].x1;
  116.                        ver[countv].y1:=lines[d1].y1;
  117.                        ver[countv].x2:=lines[d1].x2;
  118.                        ver[countv].y2:=lines[d1].y2;
  119.                      end;
  120.                   if (lines[d1].y1-lines[d1].y2)= 0 then
  121.                       begin
  122.                        counth:=counth+1;
  123.                        horz[counth].x1:=lines[d1].x1;
  124.                        horz[counth].y1:=lines[d1].y1;
  125.                        horz[counth].x2:=lines[d1].x2;
  126.                        horz[counth].y2:=lines[d1].y2;
  127.                      end;
  128.              end;
  129.              {******Points******}
  130.              i:=0;
  131.              for d2:=1 to counth do
  132.              begin
  133.                   for d1:=1 to countv do
  134.                       begin
  135.                            if (ver[d1].y2 > ver[d1].y1) and (horz[d2].x2 > horz[d2].x1)  then
  136.                            if (ver[d1].x1 >= horz[d2].x1) and (ver[d1].x1 <= horz[d2]. x2 ) and
  137.                            (horz[d2].y1 >= ver[d1].y1) and (horz[d2].y1 <=ver[d1].y2) then
  138.                              begin
  139.                                i:=i+1;
  140.                                point[i].x:=ver[d1].x1;
  141.                                point[i].y:=horz[d2].y1;
  142.                              end;
  143.                            if (ver[d1].y2 < ver[d1].y1) and (horz[d2].x2 > horz[d2].x1)  then
  144.                            if (ver[d1].x1 >= horz[d2].x1) and (ver[d1].x1 <= horz[d2]. x2 ) and
  145.                            (horz[d2].y1 <= ver[d1].y1) and (horz[d2].y1 >=ver[d1].y2) then
  146.                              begin
  147.                                i:=i+1;
  148.                                point[i].x:=ver[d1].x1;
  149.                                point[i].y:=horz[d2].y1;
  150.                              end;
  151.  
  152.                              if (ver[d1].y2 > ver[d1].y1) and (horz[d2].x2 < horz[d2].x1)  then
  153.                            if (ver[d1].x1 <= horz[d2].x1) and (ver[d1].x1 >= horz[d2]. x2 ) and
  154.                            (horz[d2].y1 >= ver[d1].y1) and (horz[d2].y1 <=ver[d1].y2) then
  155.                              begin
  156.  
  157.                                i:=i+1;
  158.                                point[i].x:=ver[d1].x1;
  159.                                point[i].y:=horz[d2].y1;
  160.                              end;
  161.                              if (ver[d1].y2 < ver[d1].y1) and (horz[d2].x2 < horz[d2].x1)  then
  162.                            if (ver[d1].x1 <= horz[d2].x1) and (ver[d1].x1 >= horz[d2]. x2 ) and
  163.                            (horz[d2].y1 <= ver[d1].y1) and (horz[d2].y1 >=ver[d1].y2) then
  164.                              begin
  165.                                i:=i+1;
  166.                                point[i].x:=ver[d1].x1;
  167.                                point[i].y:=horz[d2].y1;
  168.                                if point[i].x  < min then
  169.                                 min:=point[i].x;
  170.                                 if point[i].y  < miny then
  171.                                 miny:=point[i].y;
  172.                              end;
  173.  
  174.                       end;
  175.                   end;
  176.                   str(counth,str1);
  177.                   {******INDEX VARIABLE******}
  178.                   for j:=1 to i do
  179.                       begin
  180.                            temp:=((point[j].y-miny)*10000+(point[j].x-min));
  181.                            str(temp:6:3,str1);
  182.                            point[j].index:=str1;
  183.                       end;
  184.                       quicksort(point,1,i);
  185.          for d1:=1 to count do
  186.              begin
  187.              end;
  188.          for d1:=1 to i do
  189.              begin
  190.                   str(d1,str1);
  191.  
  192.              end;
  193.          close(f1);
  194.          assign(f2,s+'c.dxf');
  195.          rewrite(f2);
  196.          writeln(f2,'  0');
  197.          writeln(f2,'SECTION');
  198.          writeln(f2,'  2');
  199.          writeln(f2,'ENTITIES');
  200.          writeln(f2,'  0');
  201.          for d1:=1 to count do
  202.              begin
  203.                   writeln(f2,'LINE');
  204.                   writeln(f2,'  8');
  205.                   writeln(f2,'0');
  206.                   writeln(f2,' 10');
  207.                   str(lines[d1].x1:0,str1);
  208.                   writeln(f2,str1);
  209.  
  210.                   writeln(f2,' 20');
  211.                   str(lines[d1].y1:0,str1);
  212.                   writeln(f2,str1);
  213.  
  214.                   writeln(f2,' 11');
  215.                   str(lines[d1].x2,str1);
  216.                   writeln(f2,str1);
  217.  
  218.                   writeln(f2,' 21');
  219.                   str(lines[d1].y2,str1);
  220.                   writeln(f2,str1);
  221.  
  222.                   writeln(f2,'  0');
  223.              end;
  224.              for d1:=i downto 1 do
  225.              begin
  226.                   writeln(f2,'TEXT');
  227.                   writeln(f2,'  8');
  228.                   writeln(f2,'0');
  229.                   writeln(f2,' 10');
  230.                   str(point[d1].x+2,str1);
  231.                   writeln(f2,str1);
  232.  
  233.                   writeln(f2,' 20');
  234.                   str(point[d1].y-12:0,str1);
  235.                   writeln(f2,str1);
  236.  
  237.                   writeln(f2,' 40');
  238.                   writeln(f2,'10');
  239.  
  240.                   writeln(f2,'  1');
  241.                   str(i-d1+1,str1);
  242.                   writeln(f2,str1);
  243.  
  244.                   writeln(f2,'  0');
  245.              end;
  246.              writeln(f2,'ENDSEC');
  247.              writeln(f2,'  0');
  248.              writeln(f2,'EOF');
  249.              close(f2);
  250.          end.uses crt;
  251. type
  252.     lin=record
  253.       x1,y1,x2,y2,group:integer;
  254.     end;
  255.    poin=record
  256.          x,y :longint;
  257.          index:string[10];
  258.    end;
  259.      points=array [1..2200] of poin;
  260.  
  261. var
  262.    min,miny: integer;
  263.    point:points;
  264.    f1,f2,f3,f4,f